Skip to content

Conversation

adithyaa-s
Copy link
Contributor

@adithyaa-s adithyaa-s commented Jul 4, 2025

Description

close #20197

…import.meta.env.DEV' and 'import.meta.env.PROD' for conditional compilation in Vite projects with examples
@sapphi-red sapphi-red added the documentation Improvements or additions to documentation label Jul 7, 2025
@sapphi-red sapphi-red changed the title Issue #20197 Added new section to the 'Env Variables and Modes' guide explaining '… docs: add import.meta.env.DEV examples Jul 7, 2025

- **`import.meta.env.SSR`**: {boolean} whether the app is running in the [server](./ssr.md#conditional-logic).

## Conditional Compilation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need a whole section for this. I think a simple example is enough.

:::details Example
```js
if (import.meta.env.DEV) {
  // code inside here will be treeshaken
  console.log('Dev mode') 
}
```
:::

@sapphi-red sapphi-red changed the title docs: add import.meta.env.DEV examples docs: add import.meta.env.DEV example Sep 22, 2025
sapphi-red and others added 2 commits September 22, 2025 13:14
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
@sapphi-red sapphi-red merged commit 76ca3a4 into vitejs:main Sep 22, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explanation of conditional compilation in /build or /env-and-mode
2 participants